package com.factory.factorymethod.order;

import com.factory.factorymethod.pizza.Pizza;
import com.factory.simplefactory.pizzastore.order.SimpleFactory;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public abstract class OrderPizza {
    //构造器
    public OrderPizza() {
        Pizza pizza = null;
        String orderType; //订购披萨的类型
        do {
            orderType = gettype();
            pizza = createPizza(orderType); //抽象方法，由工厂子类去完成
            // 输出pizza制作过程
            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();
        }while (true);
    }

    //定义一个抽象方法，createPizza,让各个工厂子类去实现
    abstract Pizza createPizza(String orderType);

    //写一个方法，可以获取客户希望订购的披萨种类
    private String gettype() {
        try {
            BufferedReader strin = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("input pizza type:");
            String str = strin.readLine();
            return str;
        } catch (IOException e){
            e.printStackTrace();
            return "";
        }
    }
}
